#include <stdio.h>
#include <stdlib.h>
#include "3calc.h"


void push(char stack[], char value) {
	int length = len(stack);

	if (length + 1 >= STACKMAX) {
		printf("Exceeding maximum value! push char\n");
		exit(-1);
	}
	else {
		stack[length] = value;
		stack[length + 1] = '\0';
	}
}

void push(int stack[], int value) {
	int length = len(stack);

	if (length + 1 >= STACKMAX) {
		printf("Exceeding maximum value! push int\n");
		exit(-1);
	}
	else {
		stack[length] = value;
		stack[length + 1] = '\0';
	}
}

void push(double stack[], double value) {
	int length = len(stack);

	if (length + 1 >= STACKMAX) {
		printf("Exceeding maximum value! push double\n");
		exit(-1);
	}
	else {
		stack[length] = value;
		stack[length + 1] = '\0';
	}
}

int pop(char stack[]) {
	int length = len(stack);

	if (length == 0) {
		printf("Stack is empty! pop char\n");
		exit(-1);
		return '\0';
	}
	else {
		int top = stack[length - 1];

		stack[length - 1] = '\0';
		return top;
	}
}

double pop(double stack[]) {
	int length = len(stack);

	if (length == 0) {
		return 0.0;
	}
	else {
		double top = stack[length - 1];

		stack[length - 1] = '\0';
		return top;
	}
}